home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0044_VGA User Fonts.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  110 lines

  1. {
  2. >so it appears nothing happened).  I have seen some Programs that are
  3. >able to save the Dos font into a buffer in the Program and then just
  4. >set the video card back to that font when the Program quits.  The problem
  5. >is, I have not seen any documented Dos interrupt that will allow me to
  6. >do this.
  7. >  I'm wondering if anyone knows of such an interrupt that I can use to
  8. >  get the current VGA font and save it to a buffer.
  9. >  Any help would be greatly appreciated!
  10.  
  11.    Interrupt $10 is what you're looking For. Function $11,
  12.    subFunction $30 gets the Character generator info.
  13.    Function $11, subFunction $10 loads user fonts. Function $11 can
  14.    also be used to Reset to one of the hardware fonts (subFunction
  15.    $11 Resets to ROM 8x14, $12 Resets to ROM 8x8, $14 Resets to VGA
  16.    ROM 8x16)
  17.  
  18.    The structure Types are as follows:
  19. }
  20. Type
  21.  
  22.   { enumerated font Type }
  23.   ROMfont = (ROM8x14, ROM8x8, ROM8x16);
  24.  
  25.   { Character definition table }
  26.   CharDefTable = Array[0..4096] of Byte;
  27.   CharDefPtr   = ^CharDefTable;
  28.  
  29.   { Text Character generator table }
  30.   Char_Table = Record
  31.      Points :Byte;
  32.      Def    :CharDefPtr;
  33.   end;
  34.  
  35.   { font Format }
  36.   FontPackage = Record
  37.      FontInfo :Char_Table;
  38.      Ch       :CharDefTable;
  39.   end;
  40.   FontPkgPtr = ^FontPackage;
  41.  
  42. { Here are some handy Procedures to use those Types: }
  43.  
  44. Procedure GetCharGenInfo(font: ROMfont; Var Table:Char_Table);
  45. begin
  46.   if is_EGA then
  47.   begin
  48.     Reg.AH := $11;
  49.     Reg.AL := $30;
  50.     Case font of
  51.       ROM8x8 : Reg.BH := 3;
  52.       ROM8x14: Reg.BH := 2;
  53.       ROM8x16: Reg.BH := 6;
  54.     end;
  55.     Intr($10, Reg);
  56.     Table.Def := Ptr(Reg.ES, Reg.BP);
  57.     Case font of
  58.       ROM8x8 : Table.Points := 8;
  59.       ROM8x14: Table.Points := 14;
  60.       ROM8x16: Table.Points := 16;
  61.     end;
  62.   end;
  63. end;
  64.  
  65. Procedure SetHardwareFont(Var font :ROMfont);
  66. begin
  67.   if is_EGA then
  68.   begin
  69.     Reg,AH := $11;
  70.     Case font of
  71.       ROM8x14 : Reg.AL := $11;
  72.       ROM8x8  : Reg.AL := $12;
  73.       ROM8x16 :
  74.         if is_VGA then
  75.            Reg.AL := $14 { 8x16 on VGA only }
  76.         else
  77.         begin
  78.            Reg.AL := $12;
  79.            font := ROM8x14;
  80.         end;
  81.     end;
  82.     Reg.BL := 0;
  83.     Intr($10, Reg);
  84.   end;
  85. end;
  86.  
  87. Function FetchHardwareFont(font :ROMfont):FontPkgPtr;
  88. Var
  89.   pkg :FontPkgPtr;
  90. begin
  91.   New(pkg);
  92.   GetCharGenInfo(font, Pkg^.FontInfo);
  93.   Pkg^.Ch := Pkg^.FontInfo.Def^;
  94.   FetchHardwareFont := Pkg;
  95. end;
  96.  
  97. Procedure LoadUserFont(pkg :FontPkgPtr);
  98. begin
  99.   Reg.AH := $11;
  100.   Reg.AL := $10;
  101.   Reg.ES := Seg(pkg^.ch);
  102.   Reg.BP := Ofs(pkg^.ch);
  103.   Reg.BH := Pkg^.FontInfo.Points;
  104.   Reg.BL := 0;
  105.   Reg.CX := 256;
  106.   Reg.DX := 0;
  107.   Intr($10, Reg);
  108. end;
  109.  
  110.